package com.dmwork.service.message.controller.front.me;


import com.dmwork.common.base.result.R;
import com.dmwork.common.base.util.JwtInfo;
import com.dmwork.common.base.util.JwtUtils;
import com.dmwork.service.message.service.FeedFollowMessageService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户动态推送表 前端控制器
 * </p>
 *
 * @author 李天
 * @since 2021-04-27
 */
@Slf4j
@RestController
@RequestMapping("/front/dm_work/message/feed_follow/me")
public class FrontMeFeedFollowMessageController {

    @Autowired
    private FeedFollowMessageService feedFollowMessageService;

    @ApiOperation("获取当前登录用户接收的未读动态的数量")
    @GetMapping("get_unread_feed_count")
    public R getUnreadFeedCount(HttpServletRequest request) {
        JwtInfo jwtInfo = JwtUtils.getCustomerInfoByJwtToken(request);
        int count = feedFollowMessageService.getUnreadFeedCount(jwtInfo.getId());
        return R.ok().data("count", count);
    }

}

